import sha1 from '@/plugins/sha1'
import wepy from 'wepy'

export default { // 工具类
  getHeaders () {
    let htxk_token = wepy.getStorageSync('htxk_token')
    if (htxk_token) {
      let timestamp = new Date().getTime()
      let signature = sha1(htxk_token.userId + htxk_token.token + timestamp.toString())
      if (htxk_token.userId === null) {
        return
      }
      console.log(htxk_token.token)
      return {
        'X-SNS-UserId': htxk_token.userId,
        'X-SNS-Timestamp': timestamp,
        'X-SNS-Signature': signature,
        'X-SNS-ClientType': 7
      }
    } else {
      return {
        'X-SNS-ClientType': 7
      }
    }
  }
}
